package com.lihao.sam.controller;

import com.lihao.sam.dto.TeacherVitDto;
import com.lihao.sam.entity.ApartmentChaNorm;
import com.lihao.sam.entity.TeacherView;
import com.lihao.sam.service.intf.ApartmentChaNormService;
import com.lihao.sam.service.intf.TeacherViewService;
import com.lihao.sam.vo.PageVo;
import com.lihao.sam.vo.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * *  作者:陈国强
 * *  日期:2022/11/24 11:09
 * *  文件描述:
 */
@RestController
@RequestMapping("/api/TeacherView/")
public class TeacherViewController {
    @Resource
    private TeacherViewService service;
    @PostMapping("add.do")
    public R add(TeacherView chaNorm){
        return service.add(chaNorm);
    }
    @PostMapping("update.do")
    public R update(TeacherView view){
        return service.update(view);
    }
    @PostMapping("delete.do")
    public R delete(int id, HttpSession session){
        return service.delete(id);
    }
    @GetMapping("page.do")
    public PageVo page(Integer id ,String tname, String tcname,int page, int limit){
        return service.queryPage(id, tname, tcname,page, limit);
    }
    //上传Excel文件
    @PostMapping("upload.do")
    public R upload(MultipartFile file) throws IOException {
        return service.importData(file);
    }
    //下载Excel文件
    @GetMapping("download.do")
    public void downLoad(HttpServletResponse response) throws IOException {
        service.exportData(response);
    }
}
